<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加用户</title>
<link rel="stylesheet" href="${path}/static/lib/layui/css/layui.css">
<style type="text/css">
	.main_div{
		margin : 15px;
	}
</style>
</head>
<body>
  	<div class="main_div">
		<form id="form_add" onsubmit="return false" class="layui-form layui-form-pane" action="">
			<input type="hidden" id="uid" name="uid"/>
			<div class="layui-form-item">
				<label class="layui-form-label">电话</label>
				<div class="layui-input-block">
					<input type="text" id="phone" name="phone" autocomplete="off"  placeholder="请输入用户电话" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">用户名</label>
				<div class="layui-input-block">
					<input type="text" id="name" name="name" autocomplete="off"  placeholder="请输入用户名" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">密码</label>
				<div class="layui-input-block">
					<input type="password" id="password" name="password" autocomplete="off" placeholder="请输入密码" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">交易密码</label>
				<div class="layui-input-block">
					<input type="text" id="tradePwd" name="tradePwd" autocomplete="off" placeholder="请输入交易密码" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">开户银行</label>
				<div class="layui-input-block">
					<input type="text" id="bank" name="bank" autocomplete="off"  placeholder="请输入开户银行" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">开户姓名</label>
				<div class="layui-input-block">
					<input type="text" id="bankName" name="bankName" autocomplete="off" placeholder="请输入开户姓名" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">开户账号</label>
				<div class="layui-input-block">
					<input type="text" id="bankAccount" name="bankAccount" autocomplete="off"  placeholder="请输入开户账号" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">上级</label>
				<div class="layui-input-block">
					<input type="text" id="superior" name="superior" autocomplete="off" placeholder="写入推荐人ID" class="layui-input">
				</div>
			</div>


			<div class="layui-form-item">
				<label class="layui-form-label">积分</label>
				<div class="layui-input-block">
					<input type="text" id="vouchers" name="vouchers" autocomplete="off" placeholder="请输入积分值" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">金额</label>
				<div class="layui-input-block">
					<input type="text" id="money" name="money" autocomplete="off" placeholder="请输入用户金额" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">等级</label>
				<div class="layui-input-block">
					<input type="text" id="grade" name="grade" autocomplete="off"

						   placeholder="请输入用户等级"

						   class="layui-input">
				</div>
			</div>



			<div class="layui-form-item">
				<label class="layui-form-label">收货地址</label>
				<div class="layui-input-block">
					<input type="text" id="address" name="address" autocomplete="off" placeholder="请输入用户收货地址" class="layui-input">
				</div>
			</div>



			<div class="layui-form-item">
				<label class="layui-form-label">是否领导人</label>
				<div class="layui-input-block">
					<input type="text" id="isld" name="isld" autocomplete="off"  placeholder="请输入是否为领导人" class="layui-input">
				</div>
			</div>




		  <input type="button" class="layui-btn" onclick="submitForm()" value="提交"/>
		</form>
	</div>


	<script src="${path}/static/back/js/jquery.min.js?v=2.1.4"></script>
	<script src="${path}/static/common/mylayer.js"></script>
	<script src="${path}/static/common/util.js"></script>
	<script src="${path}/static/lib/layui/layui.js"></script>
	<script src="${path}/static/lib/kindeditor/kindeditor.js"></script>
	<script src="${path}/static/lib/kindeditor/lang/zh_CN.js"></script>
	<script>
	 	layui.config({
		    base : '${path}/static/lib/'
		  }).extend({
		    selectM: './layui_extends/selectM'
		  }).use(['form','upload','selectM'],function(){
		  	var form = layui.form;
		  	var upload = layui.upload;
		  	var selectM = layui.selectM;
		  	
		  	$.ajax({
				url : '${path}/role/selectAllRoles',
				type : 'POST',
				dataType : 'json',
				success : function(resp) {
					if(resp.code == util.SUCCESS) {
						mylayer.success(resp.msg);
						 //多选标签-基本配置
					    var tagIns = selectM({
					      //元素容器【必填】
					      elem: '#roles'
					      //候选数据【必填】
					      ,data: resp.data
					      //默认值
					      /* ,selected: [1,2] */
					      // 默认最多选中5个
					      ,max : 100
					    });
					} else {
						mylayer.errorMsg(resp.msg);
					}
				}
			});
		});
		
		//ajax方式提交form表单
		function submitForm(){
			$.ajax({
				url : '${path}/user/insertUser',
				data : $('#form_add').serialize(),
				type : 'POST',
				dataType : 'json',
				success : function(resp) {
					if(resp.code == util.SUCCESS) {
						//mylayer.success(jsonObj.msg);
						mylayer.confirm("添加成功，是够跳转到用户列表界面？", "${path}/user/getUserListPage");
					} else {
						mylayer.errorMsg(resp.msg);
					}
				}
			});
		}
		
	</script>
</body>
</html>